<?php
include('../../includes/classes/core.php');



$start = $_REQUEST['start'];
$end   = $_REQUEST['end'];
$cat_name = $_REQUEST['category_name'];



$result = mysql_query("SELECT 		production.`name` AS `prod_name`,
					SUM(sale_transaction_detail.product_quantity) AS `quantity`
					FROM sale_transaction
					LEFT JOIN sale_transaction_detail ON sale_transaction.id = sale_transaction_detail.transaction_id
					LEFT JOIN production ON production.id = sale_transaction_detail.production_id
					LEFT JOIN production_category ON production.pos_menu_category = production_category.id
					WHERE production_category.`name` = '$cat_name' AND `sale_transaction`.`status`=0 AND DATE(`sale_transaction`.`end_date`) >= '$start' AND DATE(`sale_transaction`.`end_date`) <= '$end' 
					GROUP BY production.`name`
		");

$rows = array();
while($r = mysql_fetch_array($result)) {
	$row[0] = $r[0];
	$row[1] = $r[1];
	array_push($rows,$row);
}



 
print json_encode($rows, JSON_NUMERIC_CHECK);



?>